﻿namespace WebOptimizer.UI.Entities
{
	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
	public sealed partial class Source : global::WebOptimizer.UI.Entities.Core.BusinessBase, global::WebOptimizer.Data.ISource
	{
		#region Business Members

		#region IgnoredFiles

		private string _IgnoredFiles = string.Empty;
		partial void OnBeforeIgnoredFilesPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
		partial void OnBeforeIgnoredFilesPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
		partial void OnAfterIgnoredFilesPropertyChanged();
		public string IgnoredFiles
		{
			get
			{
				Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_IgnoredFiles);
				OnBeforeIgnoredFilesPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				value = Sidvall.Business.ValidationManager.GetValidString(value, false, null);
				Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _IgnoredFiles);
				OnBeforeIgnoredFilesPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("IgnoredFiles", eventData.Value, true, true, true);
					OnAfterIgnoredFilesPropertyChanged();
				}
			}
		}

		#endregion
		#region IncludeSubfolders

		private bool _IncludeSubfolders = false;
		partial void OnBeforeIncludeSubfoldersPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
		partial void OnBeforeIncludeSubfoldersPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
		partial void OnAfterIncludeSubfoldersPropertyChanged();
		public bool IncludeSubfolders
		{
			get
			{
				Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IncludeSubfolders);
				OnBeforeIncludeSubfoldersPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IncludeSubfolders);
				OnBeforeIncludeSubfoldersPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("IncludeSubfolders", eventData.Value, true, true, true);
					OnAfterIncludeSubfoldersPropertyChanged();
				}
			}
		}

		#endregion
		#region IsEnabled

		private bool _IsEnabled = false;
		partial void OnBeforeIsEnabledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
		partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
		partial void OnAfterIsEnabledPropertyChanged();
		public bool IsEnabled
		{
			get
			{
				Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsEnabled);
				OnBeforeIsEnabledPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
				OnBeforeIsEnabledPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("IsEnabled", eventData.Value, true, true, true);
					OnAfterIsEnabledPropertyChanged();
				}
			}
		}

		#endregion
		#region Path

		private string _Path = string.Empty;
		partial void OnBeforePathPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
		partial void OnBeforePathPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
		partial void OnAfterPathPropertyChanged();
		public string Path
		{
			get
			{
				Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_Path);
				OnBeforePathPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				value = Sidvall.Business.ValidationManager.GetValidString(value, false, null);
				Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Path);
				OnBeforePathPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("Path", eventData.Value, true, true, true);
					OnAfterPathPropertyChanged();
				}
			}
		}

		#endregion
		#region SearchPatterns

		private string _SearchPatterns = string.Empty;
		partial void OnBeforeSearchPatternsPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
		partial void OnBeforeSearchPatternsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
		partial void OnAfterSearchPatternsPropertyChanged();
		public string SearchPatterns
		{
			get
			{
				Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_SearchPatterns);
				OnBeforeSearchPatternsPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				value = Sidvall.Business.ValidationManager.GetValidString(value, false, null);
				Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SearchPatterns);
				OnBeforeSearchPatternsPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("SearchPatterns", eventData.Value, true, true, true);
					OnAfterSearchPatternsPropertyChanged();
				}
			}
		}

		#endregion
		#region SourceId

		private System.Nullable<int> _SourceId = null;
		partial void OnBeforeSourceIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData);
		partial void OnBeforeSourceIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
		partial void OnAfterSourceIdPropertyChanged();
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
		public System.Nullable<int> SourceId
		{
			get
			{
				Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<int>>(_SourceId);
				OnBeforeSourceIdPropertyGet(eventData);
				return eventData.Value;
			}
			internal set
			{
				Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _SourceId);
				OnBeforeSourceIdPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("SourceId", eventData.Value, true, true, true);
					OnAfterSourceIdPropertyChanged();
				}
			}
		}

		#endregion
		#region TaskId

		private int _TaskId = 0;
		partial void OnBeforeTaskIdPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
		partial void OnBeforeTaskIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
		partial void OnAfterTaskIdPropertyChanged();
		public int TaskId
		{
			get
			{
				Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_TaskId);
				OnBeforeTaskIdPropertyGet(eventData);
				return eventData.Value;
			}
			set
			{
				Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _TaskId);
				OnBeforeTaskIdPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("TaskId", eventData.Value, true, true, true);
					OnAfterTaskIdPropertyChanged();
				}
			}
		}

		#endregion
		#region Task

		private Task _Task;
		partial void OnBeforeTaskPropertyChanged(Sidvall.Business.PropertyChangeEventData<Task> eventData);
		partial void OnAfterTaskPropertyChanged();
		public Task Task
		{
			get
			{
				return _Task;
			}
			set
			{
				Sidvall.Business.PropertyChangeEventData<Task> eventData = new Sidvall.Business.PropertyChangeEventData<Task>(value, _Task);
				OnBeforeTaskPropertyChanged(eventData);
				if (!eventData.Cancel)
				{
					LoadInstanceField("Task", eventData.Value, true, true, false);
					OnAfterTaskPropertyChanged();
				}
			}
		}

		#endregion
		#region IsBusy

		public override bool IsBusy
		{
			get
			{
				return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.IsBusy(this);
			}
		}

		#endregion
		#region IsDirty

		public override bool IsDirty
		{
			get
			{
				return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.IsDirty(this);
			}
		}

		#endregion

		#region LoadInstanceField

		public void LoadInstanceField(global::WebOptimizer.Data.Fields.SourceField fieldId, object value, bool cascade, bool raisePropertyChanged, bool updateState)
		{
			global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.LoadInstanceField(this, fieldId, value, cascade, raisePropertyChanged, updateState);
		}
		public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
		{
			global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
		}

		#endregion
		#region AcceptChanges

		public void AcceptChanges()
		{
			global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.AcceptChanges(this);
		}

		#endregion
		#region Copy

		public Source Copy()
		{
			return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Copy(this) as Source;
		}
		public Source Copy(Sidvall.Data.CopySettings settings)
		{
			return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Copy(this, settings) as Source;
		}

		#endregion
		#region Import

		public void Import(global::WebOptimizer.Data.ISource item)
		{
			global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Import(this, item);
		}
		public void Import(global::WebOptimizer.Data.ISource item, Sidvall.Data.CopySettings settings)
		{
			global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Import(this, item, settings);
		}

		#endregion
		#region Validate

		public Sidvall.Data.BrokenRuleCollection Validate()
		{
			return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Validate(this);
		}
		public Sidvall.Data.BrokenRuleCollection Validate(Sidvall.Data.ValidationSettings settings)
		{
			return global::WebOptimizer.UI.SystemContext.Current.EntityFacade.SourceManager.Validate(this, settings);
		}

		#endregion
		
		#region ISource Members

		string global::WebOptimizer.Data.ISource.IgnoredFiles
		{
			get
			{
				return this._IgnoredFiles;
			}
			set
			{
				this._IgnoredFiles = value;
			}
		}
		bool global::WebOptimizer.Data.ISource.IncludeSubfolders
		{
			get
			{
				return this._IncludeSubfolders;
			}
			set
			{
				this._IncludeSubfolders = value;
			}
		}
		bool global::WebOptimizer.Data.ISource.IsEnabled
		{
			get
			{
				return this._IsEnabled;
			}
			set
			{
				this._IsEnabled = value;
			}
		}
		string global::WebOptimizer.Data.ISource.Path
		{
			get
			{
				return this._Path;
			}
			set
			{
				this._Path = value;
			}
		}
		string global::WebOptimizer.Data.ISource.SearchPatterns
		{
			get
			{
				return this._SearchPatterns;
			}
			set
			{
				this._SearchPatterns = value;
			}
		}
		System.Nullable<int> global::WebOptimizer.Data.ISource.SourceId
		{
			get
			{
				return this._SourceId;
			}
			set
			{
				this._SourceId = value;
			}
		}
		int global::WebOptimizer.Data.ISource.TaskId
		{
			get
			{
				return this._TaskId;
			}
			set
			{
				this._TaskId = value;
			}
		}
		global::WebOptimizer.Data.ITask global::WebOptimizer.Data.ISource.Task
		{
			get
			{
				return this._Task;
			}
			set
			{
				UpdateChildProperty(this._Task, value);
				this._Task = value as Task;
			}
		}

		#endregion

		#endregion
		#region Constructors

		public Source()
		{
		}

		public Source(Sidvall.Data.DataRowState? dataRowState)
			: base(dataRowState)
		{
		}

		#endregion
	}
}